package com.flute.icrawler.check.checker;

import com.flute.icrawler.check.util.Util;

public class UpdateURI {
	String url;
	java.util.Date updateTime;
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public java.util.Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(java.util.Date updateTime) {
		this.updateTime = updateTime;
	}
	
	static String[]  arrays = {"index","124889"};
	String temp = "";
	
	@Override
	public boolean equals(Object obj) {
		
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final UpdateURI other = (UpdateURI) obj;
		for(String str : arrays){
			if(url.indexOf(str)!=-1 && !url.equals(temp)){
				temp = url;
				Util.saveUpateRate(url, (Math.abs(updateTime.getTime() - other.updateTime.getTime())/(1000*60)));
			}
		}
		//System.out.println((Math.abs(updateTime.getTime() - other.updateTime.getTime())/(1000*60)) );
		if (updateTime == null) {
			if (other.updateTime != null)
				return false;
		} else if ((Math.abs(updateTime.getTime() - other.updateTime.getTime())/(1000*60)) >10  )
			return false;
		if (url == null) {
			if (other.url != null)
				return false;
		} else if (!url.equals(other.url))
			return false;
		return true;
	}
	

}
